From 8137979dd323147fe541377885406a88e85fc3c4 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Tue, 10 Jan 2006 21:20:03 +0000 Subject: [PATCH] moving some more stuff from index.php to Wiki.php --- includes/Wiki.php | 24 +++++++++++++++++++++--- index.php | 18 +----------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/includes/Wiki.php b/includes/Wiki.php index 9deb9ee35b..72240dcf46 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -16,13 +16,31 @@ class MediaWiki { return $default ; } - function setCorrectArticleClass ( &$article , &$title , $namespace ) { + function initializeArticle ( &$title , $action ) { + global $wgRequest ; + if ( NS_MEDIA == $title->getNamespace() ) { + $title = Title::makeTitle( NS_IMAGE, $title->getDBkey() ); + } + + $ns = $title->getNamespace(); + + // Namespace might change when using redirects + $article = new Article( $title ); + if($action == 'view' && !$wgRequest->getVal( 'oldid' ) ) { + $rTitle = Title::newFromRedirect( $article->fetchContent() ); + if($rTitle) { + # Reload from the page pointed to later + $article->mContentLoaded = false; + $ns = $rTitle->getNamespace(); + } + } + // Categories and images are handled by a different class - if ( $namespace == NS_IMAGE ) { + if ( $ns == NS_IMAGE ) { unset($article); require_once( 'includes/ImagePage.php' ); return new ImagePage( $title ); - } elseif ( $namespace == NS_CATEGORY ) { + } elseif ( $ns == NS_CATEGORY ) { unset($article); require_once( 'includes/CategoryPage.php' ); return new CategoryPage( $title ); diff --git a/index.php b/index.php index 3f469de226..8f82ac459b 100644 --- a/index.php +++ b/index.php @@ -150,28 +150,12 @@ if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) { # actions that need to be made when we have a special pages SpecialPage::executePath( $wgTitle ); } else { - if ( NS_MEDIA == $wgTitle->getNamespace() ) { - $wgTitle = Title::makeTitle( NS_IMAGE, $wgTitle->getDBkey() ); - } - - $ns = $wgTitle->getNamespace(); - - // Namespace might change when using redirects - if($action == 'view' && !$wgRequest->getVal( 'oldid' ) ) { - $wgArticle = new Article( $wgTitle ); - $rTitle = Title::newFromRedirect( $wgArticle->fetchContent() ); - if($rTitle) { - # Reload from the page pointed to later - $wgArticle->mContentLoaded = false; - $ns = $rTitle->getNamespace(); - } - } require_once ( "includes/Wiki.php" ) ; $mediaWiki = new MediaWiki() ; - $wgArticle =& $mediaWiki->setCorrectArticleClass ( $wgArticle , $wgTitle , $ns ) ; + $wgArticle =& $mediaWiki->initializeArticle ( $wgTitle , $action ) ; if ( in_array( $action, $wgDisabledActions ) ) { $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' ); -- 2.20.1